//
//  ASHonorLevelVC.m
//  AttendenceSys
//
//  Created by 窦芳俊 on 16/4/13.
//  Copyright © 2016年 窦芳俊. All rights reserved.
//

#import "ASHonorLevelVC.h"

#define kHonorLevelCellHeight  50

@interface ASHonorLevelVC () <UITableViewDataSource, UITableViewDelegate>

@property (nonatomic, strong) UITableView *hLevelTableView;
@property (nonatomic, strong) NSArray *levelArray;

@end

@implementation ASHonorLevelVC

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    _levelArray = @[@"国家级", @"省部级", @"校级", @"院级"];
    
    self.strNavTitle = @"奖惩级别";
    self.view.backgroundColor = [UIColor whiteColor];
    
    _hLevelTableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
    _hLevelTableView.frame = CGRectMake(0, 0, self.view.frame.size.width, 200);
    _hLevelTableView.delegate = self;
    _hLevelTableView.dataSource = self;
    _hLevelTableView.backgroundColor = [UIColor whiteColor];
    _hLevelTableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
    _hLevelTableView.rowHeight = kHonorLevelCellHeight;
    [self.view addSubview:_hLevelTableView];
    
    [_hLevelTableView reloadData];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
}

#pragma mark - UITableViewDataSource

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [_levelArray count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:@"honorLevelTableViewCellIdentifier"];
    if (cell == nil)
    {
        cell = [[UITableViewCell alloc] init];
    }
    
    cell.textLabel.text = [_levelArray objectAtIndex:[indexPath row]];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    
    return cell;
}

#pragma mark - UITableViewDelegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    if (self.delegate && [self.delegate respondsToSelector:@selector(selectHonorLevel:)])
    {
        [self.delegate selectHonorLevel:[_levelArray objectAtIndex:[indexPath row]]];
    }
}

@end



